﻿<Page
    x:Class="Ch9RSS_Universal.SectionPage"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="using:Ch9RSS_Universal"
    xmlns:data="using:Ch9RSS_Universal.Data"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    mc:Ignorable="d"
    xmlns:convert="using:Ch9RSS_Universal.Converters"
   Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
    <Page.Transitions>
        <TransitionCollection>
            <NavigationThemeTransition>
                <NavigationThemeTransition.DefaultNavigationTransitionInfo>
                    <ContinuumNavigationTransitionInfo/>
                </NavigationThemeTransition.DefaultNavigationTransitionInfo>
            </NavigationThemeTransition>
        </TransitionCollection>
    </Page.Transitions>
    <Page.Resources>
        <convert:ThumbConverter x:Key="ThumbConverter" />
        <convert:GroupToMediaConverter x:Key="GroupToMedia" />
        <x:Double x:Key="targetSize">240</x:Double>
        <!-- Collection of items displayed by this page -->
       </Page.Resources>
    <!--
        This grid acts as a root panel for the page that defines two rows:
        * Row 0 contains the page title
        * Row 1 contains the rest of the page layout
    -->
    <Grid>
        <Grid.ChildrenTransitions>
            <TransitionCollection>
                <EntranceThemeTransition/>
            </TransitionCollection>
        </Grid.ChildrenTransitions>

        <Grid.RowDefinitions>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="*"/>
        </Grid.RowDefinitions>

        <!-- TitlePanel -->
        <StackPanel Grid.Row="0" Margin="0,0,0,0" Background="{StaticResource Ch9Orange}">
            <TextBlock Margin="20,5,0,0" Foreground="White"  Text="CHANNEL 9 VIEWER" Style="{ThemeResource TitleTextBlockStyle}" Typography.Capitals="SmallCaps"/>
            <TextBlock Text="{Binding SelectedSeries}" Foreground="White"  
                       Margin="20,12,0,12" Style="{ThemeResource SubheaderTextBlockStyle}" MaxLines="2" TextWrapping="Wrap"/>
        </StackPanel>

        <ListView
            x:Name="itemGridView"
            TabIndex="1"
            Grid.Row="1"
            Padding="12,0,0,0"
            ItemsSource="{Binding SeriesItems}"
            SelectedItem="{Binding SelectedItem, Mode=TwoWay}"
            SelectionChanged="itemGridView_SelectionChanged"
            Grid.RowSpan="2" >
            <ListView.ItemTemplate>
                <DataTemplate>
                    <Grid Margin="10" >
                        <Border x:Name="parentBorder" Background="{ThemeResource ListViewItemPlaceholderBackgroundThemeBrush}" >
                            <Image Source="{Binding thumbnail, Converter={StaticResource ThumbConverter}, ConverterParameter={StaticResource targetSize}}" 
                                   Stretch="UniformToFill" 
                                   AutomationProperties.Name="{Binding Title}" 
                                   />
                        </Border>
                        <StackPanel VerticalAlignment="Bottom" Margin="0,0,0,0" Background="#CCF97600">
                            <TextBlock Text="{Binding title}" 
                                       Foreground="White" 
                                       Style="{StaticResource TitleTextBlockStyle}" 
                                       TextWrapping="Wrap" 
                                       MaxLines="3" 
                                       Margin="5,5,5,10" FontSize="18" 
                                       FontFamily="Global User Interface" />
                        </StackPanel>
                    </Grid>
                </DataTemplate>
            </ListView.ItemTemplate>
            <ListView.ItemContainerStyle>
                <Style TargetType="FrameworkElement">
                    <Setter Property="Margin" Value="0,0,0,2"/>
                </Style>
            </ListView.ItemContainerStyle>
        </ListView>
    </Grid>
</Page>
